package com.qingcheng.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.pojo.seckill.SeckillGoods;
import com.qingcheng.service.seckill.SeckillGoodsService;
import com.qingchneg.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/seckill/goods")
public class SeckillGoodsController {

    @Reference
    private SeckillGoodsService seckillGoodsService;
    /**
     * 加载所有时间菜单
     * @return
     */
    @GetMapping("/menus")
    public List<Date> loadMenus(){
        return DateUtil.getDateMenus();
    }


    /**
     * 加载对应时区的秒杀商品
     */
@GetMapping("/list")
    public List<SeckillGoods> list(String time){

    List<SeckillGoods> list = seckillGoodsService.list(time);
    System.out.println(list);
    return list;
}


    /****
     * URL:/seckill/goods/one
     * 根据ID查询商品详情
     * 调用Service查询商品详情
     * @param time
     * @param id
     */
    @RequestMapping(value = "/one")
    public SeckillGoods one(String time,Long id){
        //调用Service查询商品详情
        return seckillGoodsService.one(time,id);
    }

}
